package com.sz.mes.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.diboot.core.util.BeanUtils;
import com.sz.mes.entity.GoodsType;
import com.sz.mes.mapper.GoodsTypeMapper;
import com.sz.mes.service.GoodsTypeService;
import com.sz.mes.service.impl.BaseCustomServiceImpl;
import com.sz.mes.vo.GoodsTypeDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.io.Serializable;

/**
* 商品类型相关Service实现
* @author hem
* @version 1.0
* @date 2023-04-03
 * Copyright © szhs
*/
@Service
@Slf4j
public class GoodsTypeServiceImpl extends BaseCustomServiceImpl<GoodsTypeMapper, GoodsType> implements GoodsTypeService {

    @Override
    public List<GoodsTypeDetailVO> getGoodsTypeTree(Serializable rootId) {
        LambdaQueryWrapper<GoodsType> queryWrapper = new LambdaQueryWrapper<GoodsType>();
        queryWrapper.orderByAsc(GoodsType::getId);
        List<GoodsType> goodsTypeList = getEntityList(queryWrapper);
        List<GoodsTypeDetailVO> goodsTypeDetailVOList = BeanUtils.convertList(goodsTypeList, GoodsTypeDetailVO.class);
        return BeanUtils.buildTree(goodsTypeDetailVOList, rootId);
    }

}
